//
// Created by XMac on 16/6/20.
// Copyright (c) 2016 XBN. All rights reserved.
//

#import <Foundation/Foundation.h>

/**
 *  @author taohebin, 16-06-20 15:06:00
 *
 *  这个计算对象简单的进行时间倒计时的开始与取消
 *  具体用例如下:
 
 -(void)testTimeLimit{
 timeLimit = [XBNTimeLimitCountDownCalculator new];
 __weak typeof(self) weakSelf = self;
 [timeLimit addProcessBlock:^{
 [weakSelf processMethod];
 } cancelBlock:^{
 [weakSelf cancelMethod];
 }];
 
 timeLimit.remainTimeInterval = 10;
 
 [timeLimit timeLimitCountDownResume];
 }
 
 -(void)processMethod{
 contentLabel.text = [NSString stringWithFormat:@"剩余 %.0f",timeLimit.remainTimeInterval];
 }
 
 -(void)cancelMethod{
 contentLabel.text = @"结束了";
 }
 
 */

typedef void(^TimeLimitProcessBlock)(NSTimeInterval remain);
typedef void(^TimeLimitCancelBlock)();

@interface XBNTimeLimitCountDownCalculator : NSObject

///剩余的时间 单位s
@property(nonatomic , assign) NSTimeInterval remainTimeInterval;

/**
 *  @author taohebin, 16-06-21 16:06:34
 *
 *  添加每秒执行的块 和  完成或结束的时候执行的block
 *
 */
-(void)addProcessBlock:(TimeLimitProcessBlock)xProcessBlock cancelBlock:(TimeLimitCancelBlock)xCancelBlock;


/**
 *  @author taohebin, 16-06-21 16:06:06
 *
 *  正式开始计时  这个方法再次调用会重置原先的设置
 */
-(void)timeLimitCountDownResume;
/**
 *  @author taohebin, 16-06-21 16:06:16
 *
 *  取消计时  直接取消不会有任务提示
 */
-(void)timeLimitCountDownClear;

@end
